<?php
namespace app\common\model;
use app\common\traits\Text;
use think\Model;
use think\Db;
use app\admin\model\State;

class Order_log extends Model
{
    use Text;
    protected $type = [
        'cztime'=>'timestamp:Y-m-d  G:i',//最后操作时间
        'yctime'=>'timestamp:Y-m-d  G:i',
        'yctime'=>'timestamp:Y-m-d',//预产期
    ];

    /* 更新日志 */
    public function log($data,$khd=1){
        $data['khd']  = $khd;
        $data['czry'] = session("admin_user.adminid");
        $data['ip']  = request()->ip();
        $data['cztime'] = time();
        $data['status'] = 1;
        if(empty($data['ids'])){
            $data['order_id'] = $data['id'];
            unset($data['id']);
            $re = $this->save($data);
        }else{//批量操作
            $tmps =[];
            $datas = $data;
            unset($datas['ids']);
            foreach ($data['ids'] as $v){
                $tmp['order_id'] = $v;
                $tmps[]= array_merge($tmp,$datas);
            }
            $re = $this->allowField(['yykf','hsdzid','hszzid','order_id','khd','czry','ip','cztime','status','operation','automsgflag'])->saveAll($tmps);
//            $re = $this->allowField(['yykf','hsdzid','hszzid','order_id','khd','czry','ip','cztime','status','operation'])->saveAll($tmps);
            unset($datas);
            unset($tmps);
            unset($tmp);
        }
        if($re){
            return true;
        }else{
            return  false;
        }
    }

    public static function Khd()
    {
        return [1=>'PC端',2=>'手机端',3=>'系统处理'];
        
    }

    public static function Operation()
    {
        return [
            1=>"新增订单",
            2=>"修改订单",
            3=>"删除订单",
            4=>"分配专员",
            5=>"分配会所",
            6=>"意向反馈",
            7=>"短信发送",
            9=>"金牌匹配",
            8=>"邀约拍摄",
            10=>"分配专员自动发短信",
            11=>"预约拍摄自动发短信",
            12=>"预约上课自动发短信",
            13=>'分配一月自动发短信',
            14=>'分配三月自动发短信',
            15=>'渠道导入自动发短信',
            16=>'医院上课批量发短信',
            17=>'儿博会批量推广短信',
            18=>'恢复邀约备注',
            19=>'温馨提示短信',
            20=>'预约一月系统提示短信',
            21=>'导入修改数据'
        ];
    }

}	